package com.cy.pj.sys.controller;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.sys.entity.SysMenu;
import com.cy.pj.sys.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;


    @CrossOrigin
    @RequestMapping("/menu/doFindObjects")
    public JsonResult doFindObjects(){
        return new JsonResult(sysMenuService.findObjects());
    }

    @CrossOrigin
    @RequestMapping("/menu/doDeleteObject")
    public JsonResult doDeleteObject(Integer id){
        sysMenuService.deleteObject(id);
        return new JsonResult("delete OK");
    }

    @RequestMapping("/menu/doFindZtreeMenuNodes")
    public  JsonResult doFindZtreeMenuNodes(){
       return new JsonResult(sysMenuService.findZtreeMenuNodes());
    }

    @RequestMapping("/menu/doSaveObject")
    public JsonResult doSaveObject(SysMenu entity){
        sysMenuService.insertObject(entity);
        return new JsonResult("save Ok");
    }

    @RequestMapping("/menu/doUpdateObject")
    public JsonResult doUpdateObject(SysMenu entity){
        sysMenuService.updateOject(entity);
        return new JsonResult("update Ok");
    }
}